<?php
/**
 *   Joomdiet - components/controller.php
 *   Author: Juan Dapena Paz (juan@bittingbits.com)
 *   Copyright (C) 2010 Bitting Bits S.L.
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');

/**
 * joomdiet Component Controller
 */
class JoomdietController extends JController {

	function __construct() {
        // Make sure we have a default view
        if( !JRequest::getVar( 'view' )) {
		    JRequest::setVar('view', 'joomdiet' );
        }
		parent::__construct();
	}
	
	function foodsearch()
	{
	    JRequest::setVar('view', 'foodsearch');
	    $view =& $this->getView('foodsearch', 'html');
	    
	    $view->setModel($this->getModel('Food'), true);
	    $view->setModel($this->getModel('FoodCategory'));
	    $view->setModel($this->getModel('Variable'));
	    
	    $view->display();
	}
	
	function recipesearch()
	{
	    JRequest::setVar('view', 'recipesearch');
	    $view =& $this->getView('recipesearch', 'html');
	    
	    $view->setModel($this->getModel('Recipe'), true);
	    $view->setModel($this->getModel('RecipeCategory'));
	    $view->setModel($this->getModel('Variable'));
	    
	    $view->display();
	}
	
	function dietcalibrator()
	{
	    JRequest::setVar('view', 'dietcalibrator');
	    $view =& $this->getView('dietcalibrator', 'html');
	    
	    $view->setModel($this->getModel('Recipe'), true);
	    $view->setModel($this->getModel('RecipeFood'));
	    $view->setModel($this->getModel('Food'));
	    
	    $view->display();
	}
	
	function recommended()
	{
	    JRequest::setVar('view', 'recommendedingests');
	    $view =& $this->getView('recommendedingests', 'html');
	    
	    $view->display();
	}
	
	function energeticspend()
	{   
	    $view =& $this->getView('energeticspend', 'html');
	    
	    $view->setModel($this->getModel('physicalactivity'), true);
	    
	    $view->display();
	}
}
?>
